<?php 
$cs=Yii::app()->clientScript;
$cs->registerCssFile(Yii::app()->baseUrl.'/css/common.css');
$cs->registerScript('news_admin',<<<END
$("#sel_all").toggle(
function(){
	$(this).val('全否');
	$("input[type=checkbox]").attr("checked",true);
},
function(){
	$(this).val('全选');
	$("input[type=checkbox]").attr("checked",false);
}
);
$("form:eq(1)").submit(
function(){
	if($("input[type=checkbox]:checked").length==0){alert("请选择要删除的信息!");return false;}
	return confirm('确定要删除已选中信息吗？');
});
END
);
?>
<h2>文章管理</h2>
<?php echo CHtml::beginForm(array('news_admin'),'post');?>
文章标题：<input type="text" name="keys[title]" size="7" value="<?php echo isset($_GET['keys']['title'])?$_GET['keys']['title']:'';?>"/>
模糊查询：<?php echo CHtml::radioButtonList('keys[blur]',isset($_GET['keys']['blur'])?$_GET['keys']['blur']:'1', array('1'=>'是','0'=>'否'),array('separator'=>''));?>
文档类型：<?php echo CHtml::dropDownList('keys[kind]', isset($_GET['keys']['kind'])?$_GET['keys']['kind']:'', array(''=>'全部',1=>'行业信息',2=>'专业知识',3=>'北京家具城导航',4=>'企业名录',5=>'政策法规',6=>'软文'));?>
<input type="submit" value="搜索"/>
<?php echo CHtml::endForm();?>
<?php echo CHtml::beginForm(array('delete_news')+$_GET,'post');?>
<input id="sel_all" type="button" value="全选"/><input type="submit" value="删除选中"/>
<table class="dataGrid" width="730">
  <thead>
  <tr>
 	<th width="60">选择</th>
    <th width="400"><?php echo $sort->link('title'); ?></th>
    <th width="150"><?php echo $sort->link('kind'); ?></th>
    <th width="200"><?php echo $sort->link('create_time'); ?></th>
	<th width="120">操作</th>
  </tr>
  </thead>
  <tbody>
<?php foreach($models as $n=>$model): ?>
  <tr class="<?php echo $n%2?'even':'odd';?>">
  	<td><input type="checkbox" name="ids[]" value="<?php echo $model->id;?>"/></td>
  	<?php $url=array('news/get_news','id'=>$model->id)+$_GET;?>
    <td><?php echo CHtml::link($model->title,$url,array('target'=>'_blank')); ?></td>
    <td><?php echo CHtml::encode($model->getKindName()); ?></td>
    <td><?php echo CHtml::encode($model->create_time); ?></td>
    <td>
     <?php echo CHtml::link('修改',array('update_news','id'=>$model->id)+$_GET); ?>
     <?php echo CHtml::link('删除',array('delete_news','id'=>$model->id)+$_GET,array('confirm'=>"确定要删除 {$model->title} 的文章吗？")); ?>
    </td>
  </tr>
<?php endforeach; ?>
  </tbody>
</table>
</form>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'htmlOptions'=>array('style'=>'width:900px;'))); ?>